<template>
	<view class="container padding-top-lg">
		<scroll-view scroll-x class="bg-white nav">
			<view class="flex text-center"><!-- 0所有  1审核中 2提现成功 3提现失败 -->
				<view class="cu-item flex-sub" :class="0==TabCur?'text-blue cur':''" 
				@tap="tabSelect" :data-id="0" :data-num="0">全部</view>
				<view class="cu-item flex-sub" :class="1==TabCur?'text-blue cur':''"
				@tap="tabSelect" :data-id="1" :data-num="2">提现成功</view>
				<view class="cu-item flex-sub" :class="2==TabCur?'text-blue cur':''"
				@tap="tabSelect" :data-id="2" :data-num="1">审核中</view>
				<view class="cu-item flex-sub" :class="3==TabCur?'text-blue cur':''"
				@tap="tabSelect" :data-id="3" :data-num="3">提现失败</view>
			</view>
		</scroll-view>
		<view class="cu-list menu" v-for='(item,index) of list' :key='index'>
			<view class="cu-item arrow">
				<view class="content padding-tb-sm">
					<view>
						<text class="margin-right-xs text-black text-lg">余额-提现到{{item.payment_method}}</text>
						<text v-if="item.failure_reason">{{item.failure_reason}}</text>
					</view>
					<view class="text-gray text-df">{{item.withdrawal_time}}</view>
					<view class="text-gray text-df">剩余余额：{{item.account_balance}}</view>
				</view>
				<view class="action"><!-- // 0 审核中 1提现成功 2提现失败 -->
					<view class="text-df" style="color: #0CBF88;">+{{item.withdrawal_money}}</view>
					<view v-if="item.withdrawal_state==0" class="text-df" style="color: #E08795">审核中</view>
					<view v-if="item.withdrawal_state==1" class="text-df" style="color: #E08795">提现成功</view>
					<view v-if="item.withdrawal_state==2" class="text-df" style="color: #E08795">提现失败</view>
				</view>
			</view>
		</view>
		<view v-if="list.length==0" class="text-center padding-top-lg">
			  <image src='../../common/img/no_data.png' style="width:275rpx;height:312rpx;"></image>
		</view>
	</view>
</template>

<script>
	let page=1,timer=null
	export default {
		data() {
			return {
				scrollTop: 0,
				TabCur: 0,
				list:[],
				state:"",
				type:''
			}
		},
		onLoad(options) {
			this.type=options.type
		},
		onShow() {
			page=1;
			this.getlist();
		},
		methods: {
			//页面滚动执行方式
			onPageScroll(e) {
				this.scrollTop = e.scrollTop
			},
			tabSelect(e) {
				this.TabCur = e.currentTarget.dataset.id;
				this.state = e.currentTarget.dataset.num;
				page=1;
				this.list=[];
				this.getlist();
			},
			getlist(){
				let that=this;
				that.http.tokenreq({
					url: 'user/v1/withdrawalpage',
					data:{
						'pageindex':page,
						'withdrawal_state':this.state,
						"withdrawal_type": this.type
					}
				}).then((res) => {
					let e=res.data;
					console.log("e="+JSON.stringify(e));
					if(e.code==0 && e.success){
					   let list=e.rows;
					   that.list = e.rows;
					   page++;
					}
				})
			},
			getmorelist(){
				this.loadingTxt='加载中'
				let that=this;
				that.http.tokenreq({
					url: 'user/v1/withdrawalpage',
					data:{
						'pageindex':page,
						'withdrawal_state':this.state,
						"withdrawal_type": this.type
					}
				}).then((res) => {
					uni.hideLoading();
					let e=res.data;
					if(e.code==0 && e.success){
						if(e.rows.length==0){
							that.loadingTxt="已经加载全部";
							return;
						}
						let list=e.rows;
						that.list=that.list.concat(e.rows);
						page++;
					}
				})
			},
			onReachBottom() {
				//阻止重复加载
				if(timer !== null){
					clearTimeout(timer)
				}
				timer=setTimeout(()=>this.getmorelist(),500)
			}
		}
	}
</script>


<style>
	.container {
		padding-bottom: env(safe-area-inset-bottom);
	}
	
	.tips {
		background: #fff;
		padding: 50rpx 34rpx;
		color: #555;
		font-size: 24rpx;
		line-height: 42rpx;
		position: relative;
	}
	
	.tips::before {
		content: '';
		position: absolute;
		border-top: 1rpx solid #eaeef1;
		-webkit-transform: scaleY(0.5);
		transform: scaleY(0.5);
		top: 0;
		right: 0;
		left: 0;
	}
	
	/* sticky 容器 start */
	.sticky-item {
		width: 100%;
		height: 104rpx;
		padding: 20rpx 30rpx;
		background-color: #fafafa;
		display: flex;
		align-items: center;
		justify-content: space-between;
		box-sizing: border-box;
	}
	
	/* sticky 容器 end */
	
	.date {
		height: 54rpx;
		font-size: 28rpx;
		background-color: #fff;
		padding: 0 28rpx;
		border-radius: 25rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		position: relative;
		/* box-shadow: 0 0 1rpx #7A7A7A; */
	}
	
	.date::after {
		content: '';
		position: absolute;
		height: 200%;
		width: 200%;
		border: 1rpx solid #eaeef1;
		border-radius: 60rpx;
		-webkit-transform-origin: 0 0;
		transform-origin: 0 0;
		-webkit-transform: scale(0.5);
		transform: scale(0.5);
		left: 0;
		top: 0;
	}
	
	.amount {
		text-align: right;
		color: #7A7A7A;
		font-size: 24rpx;
	}
	
	.list-view {
		position: relative;
		width: 100%;
		overflow: hidden;
	}
	
	.list-view::after {
		content: '';
		position: absolute;
		border-top: 1rpx solid #eaeef1;
		-webkit-transform: scaleY(0.5);
		transform: scaleY(0.5);
		top: 0;
		right: 0;
		left: 0;
	}
	
	.tui-list-item {
		width: 100%;
		padding:10rpx 10rpx;
		box-sizing: border-box;
		background-color: #fff;
		display: flex;
		align-items: flex-start;
		justify-content: space-between;
	}
	
	.tui-list-item::after {
		left: 120rpx
	}
	
	.item-last::after {
		left: 0 !important
	}
	
	.content-box {
		display: flex;
		align-items: flex-start;
		justify-content: space-between;
	}
	
	.logo {
		width: 60rpx;
		height: 60rpx;
		flex-grow: 1
	}
	
	.des-box {
		min-height: 130rpx;
		padding-left: 28rpx;
		box-sizing: border-box;
		vertical-align: top;
		color: #333;
		font-size: 24rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}
	
	.tit {
		font-size: 32rpx;
		max-width: 420rpx;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}
	
	.time {
		color: #888
	}
	
	.money {
		font-size: 38rpx;
		font-weight: 500;
		color: #000;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		padding-left: 20rpx;
	}
	
	.add {
		color: #5677FC !important;
	}
	
	.tui-color-primary {
		color: #5677fc;
	}
</style>
